<template>
	<view class="page">
		<view class="container">			
			<view class="header">
				<!-- 中间搜索栏 -->
				<view class="searchbar">
					<image src="../../../static/icons2/search.png" class="search-ico"></image>
					<input type="text" value="" class="search-input" placeholder="输入学生学号或姓名" @confirm="search" />
					<!-- <image src="../../../static/res/delete.png" class="delete-ico"></image> -->
				</view>
			</view>		
				
			<view class="search-result" v-if="stuList.length > 0">
				<view class="item-wrapper" v-for="(stu,index) in stuList" @click="click(stu.id)">
					<view class="item">
						<view class="left">
							<image :src="stu.avatarUrl" class="avatar"></image>
						</view>
						
						<view class="middle">
							<text class="name">{{stu.name}}</text>
							<text class="clazz">{{stu.clazz}}</text>
						</view>
						
						<view class="right">
							
							<image src="@/static/icons/left-gray-arrow.png" class="arrow"></image>
						</view>
					</view>
					
					<view class="line" v-if="index < stuList.length - 1"></view>
				</view>
				
			</view>	
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				stuList: []
			}
		},
		methods: {
			search(e) {
				// 获取搜索关键字
				const keyword = e.detail.value;
				
				// 发出请求，得到搜索结果列表
				
				this.stuList = [
					{
						id: "1001",
						name: '李安国',
						clazz: '高一(02)',
						avatarUrl: 'https://s3.bmp.ovh/imgs/2021/09/13041958120ca251.jpg',
					},
					{
						id: "1002",
						name: '李安国',
						clazz: '高二(03)',
						avatarUrl: 'https://s3.bmp.ovh/imgs/2021/09/13041958120ca251.jpg',
					},
					{
						id: "1003",
						name: '李安国',
						clazz: '高三(01)',
						avatarUrl: 'https://s3.bmp.ovh/imgs/2021/09/13041958120ca251.jpg',
					},
					{
						id: "1004",
						name: '李安国',
						clazz: '高三(04)',
						avatarUrl: 'https://s3.bmp.ovh/imgs/2021/09/13041958120ca251.jpg',
					}
				];
			},
			
			click(e) {
				const id = e;
				uni.navigateTo({
					url:'student-detail/student-detail?id=' + id,
				})
			}
		}
	}
</script>

<style lang="less">
	
	.line {
		height: 1px;
		background-color: rgba(0,0,0,0.2);
		margin-left: 50upx;
		margin-right: 50upx;
	}
	@import url('./student.less');
</style>
